import React from 'react';
import classnames from 'classnames';

export default class view extends React.Component {
    static propTypes = {
        label: React.PropTypes.any.isRequired,
        value: React.PropTypes.any.isRequired,
        selected: React.PropTypes.bool.isRequired
    };

    static defaultProps = {
        label: '',
        value: '',
        selected: false
    }
    constructor(props, context) {

        super(props, context);


        // init state;
        this.state = {
            selected: props.selected
        };
    }
    componentWillMount() {
        this._isMounted = true;
    }

    componentDidMount() {

    }

    componentWillUnmount() {
        this._isMounted = false;
    }

    handleSelectedClick = (event) => {
        if (this.props.onSelectClick) {
            this.props.onSelectClick(this.props.value, this.props.label);
        }
    }

    render() {
        let classNames = classnames({
            'segments-item': true,
            'active': this.props.selected
        });
        return (
            <div className={classNames} onClick={(event) => this.handleSelectedClick(event) } >{this.props.label}</div>
        );
    }
}
